package com.hwhhhh.mygrad.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import com.hwhhhh.mygrad.MessageActivity;
import com.hwhhhh.mygrad.fragment.MessageFragment;

public class MessageViewpagerAdapter extends FragmentStateAdapter {

    public MessageViewpagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    public MessageViewpagerAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    public MessageViewpagerAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case MessageActivity.MENTION:
                return new MessageFragment(MessageActivity.MENTION);
            case MessageActivity.REPLY:
                return new MessageFragment(MessageActivity.REPLY);
            case MessageActivity.LIKE:
                return new MessageFragment(MessageActivity.LIKE);
            case MessageActivity.PRIVATE:
                return new MessageFragment(MessageActivity.PRIVATE);
        }
        return new MessageFragment(MessageActivity.MENTION);
    }

    @Override
    public int getItemCount() {
        return 4;
    }
}
